﻿@using Ext.Net
@using Ext.Net.MVC
@{
    ViewBag.Title = "ListGroupDishes";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Header
{
    <script>
        function deleterecord() {
            if (App.GDishesDataGrid.getSelectionModel().getSelection()[0] == null) {
                alert('No contact selected');
                return;
            }
            var id = App.GDishesDataGrid.getSelectionModel().getSelection()[0].get('GroupDishesId');
        }

        function editrecord() {
            if (App.GDishesDataGrid.getSelectionModel().getSelection()[0] == null) {
                alert('No record selected');
                return;
            }
            var id = App.GDishesDataGrid.getSelectionModel().getSelection()[0].get('GroupDishesId');
            showWindow('Edit GroupDishes', '/Dishes/EditGroupDishes/' + id, true, 0.85, 0.85);

        }

    </script>
    
    
}

@section ToolbarSection
{
@Html.X().ToolbarTextItem().Text("<h3 style=\"color:blue\">List GroupDishes</h3>")
}

@(Html.X().GridPanel()
      .ID("GDishesDataGrid")
      .Frame(true)
      .Border(false)
      .Store(
          Html.X().Store()
              .ID("GDishesDataStore")
              .Model(
                  Html.X().Model()
                      .IDProperty("GroupDishesId")
                      .Fields(
                          new ModelField("GroupDishesId",ModelFieldType.Int),
                          new ModelField("GroupName"),
                          new ModelField("Image"),
                          new ModelField("Description"),
                          new ModelField("IsActive")
                             )
                    )
               .RemoteSort(true)
               .RemotePaging(true)
               .RemoteFilter(true)
               .PageSize(10)
               .Proxy(
                      Html.X().AjaxProxy()
                              .Url(Url.Action("GroupDishesData"))
                              .Reader(Html.X().JsonReader().Root("data"))
                     )
            )
      .ColumnModel(
          Html.X().Column().Text("ID").DataIndex("GroupDishesId").Flex(1),
          Html.X().Column().Text("Name").DataIndex("GroupName").Flex(3),
          Html.X().Column().Text("Group Photo").DataIndex("Image").Flex(3),
          Html.X().Column().Text("Description").DataIndex("Description").Sortable(false).Flex(5),
          Html.X().Column().Text("Is Active?").DataIndex("IsActive").Flex(1),
          Html.X().CommandColumn().Text("Edit").Commands(
          Html.X().GridCommand().CommandName("Edit").Icon(Icon.NoteEdit).ToolTip(tt => tt.Text = "Edit Record"))
                .Listeners(ls => ls.Command.Handler = "editrecord();").Flex(1),
          Html.X().CommandColumn().Text("Delete").Commands(
          Html.X().GridCommand().CommandName("Delete").Icon(Icon.Delete).ToolTip(tt => tt.Text = "Delete Record"))
                .Listeners(ls => ls.Command.Handler = "deleterecord();").Flex(1)
                   )
          .BottomBar(Html.X().PagingToolbar()))